package com.leo.entity;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.dsl.components.LiftComponent;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.leo.component.DialogComponent;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-17  23:00
 * @Description: TODO
 */
public class DialogEntityFactory implements EntityFactory {

    @Spawns("rect")
    public Entity createRect(SpawnData spawnData) {
        // 电梯组件
        LiftComponent liftComponent = new LiftComponent();
        liftComponent.setGoingRight(true);
        liftComponent.xAxisDistanceDuration(200, Duration.seconds(1.8));

        return FXGL.entityBuilder(spawnData)
                .view(new Rectangle(100, 100, Color.BURLYWOOD))
                .with(new DialogComponent())
                .with(liftComponent)
                .build();
    }

    @Spawns("bg")
    public Entity createBg(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                .view((Node) spawnData.get("imageView"))
                .zIndex(Integer.MIN_VALUE)
                .build();
    }
}
